<template>
  <el-menu v-if="store.state.user.userInfo.roler == 'admin'"
    :default-active="activePath"
    class="el-menu-vertical-demo"
    :router="true">
<!--    @select="selectfun"-->
    <el-menu-item index="/home/data">
      <el-icon><icon-menu /></el-icon>
      <template #title>数据展示</template>
    </el-menu-item>


    <el-sub-menu index="1">
      <template #title>
        <el-icon><Avatar /></el-icon>
        <span>员工管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/emps">员工信息</el-menu-item>
<!--        <el-menu-item index="/">添加员工</el-menu-item>-->
        <el-menu-item index="/home/addemps">添加员工</el-menu-item>
        <el-menu-item index="/home/addemps2">添加管理员</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>

    <el-sub-menu index="2">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>部门管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/deps">部门信息</el-menu-item>
        <el-menu-item index="/home/adddeps">添加部门</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>

    <el-sub-menu index="3">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>薪资管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/salary">薪资信息</el-menu-item>
        <el-menu-item index="/home/addSalary">添加薪资</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>

    <el-sub-menu index="4">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>药品管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/medicine">药品信息</el-menu-item>
        <el-menu-item index="/home/addMedicine">添加药品</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>



    <el-sub-menu index="0">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>病房管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/room">病房信息</el-menu-item>
        <el-menu-item index="/home/addRoom">添加病房</el-menu-item>
        <el-menu-item index="/home/bed">病床信息</el-menu-item>
        <el-menu-item index="/home/addbed">添加病床</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>

    <el-sub-menu index="6">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>挂号数管理</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/regnus">挂号数信息</el-menu-item>
        <el-menu-item index="/home/addregnus">添加挂号数</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>


    <el-sub-menu index="5">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>用户相关信息</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/patient">患者信息</el-menu-item>
        <el-menu-item index="/home/reg">挂号信息</el-menu-item>
        <el-menu-item index="/home/seeDoctor">就诊信息</el-menu-item>
        <el-menu-item index="/home/inhospital">住院信息</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>
  </el-menu>

<!--  v-if="store.state.user.userInfo.roler === 'user'"-->
  <el-menu v-else
           :default-active="activePath"
           class="el-menu-vertical-demo"
           :router="true">
    <!--    @select="selectfun"-->
    <el-sub-menu index="5">
      <template #title>
        <el-icon><icon-menu /></el-icon>
        <span>就诊信息</span>
      </template>
      <el-menu-item-group>
        <el-menu-item index="/home/dReg">挂号信息</el-menu-item>
        <el-menu-item index="/home/dSee">就诊信息</el-menu-item>
        <el-menu-item index="/home/dIn">住院信息</el-menu-item>
      </el-menu-item-group>
    </el-sub-menu>
  </el-menu>
</template>

<script lang="ts" setup>
import { ref,computed } from 'vue'
const store = useStore();
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'
import { useRouter } from "vue-router";
import { useStore } from "vuex";

const router = useRouter();
// const selectfun = (index) => {
//   router.push({
//     path:index
//   })
// }

/**
 * 解决页面刷新，菜单选中情况
 */
let activePath = '/home/emps'; // 当前默认激活客户管理界面
let activePath2 = '/home/dReg'; // 当前默认激活客户管理界面
const setActivePath = () => { // 获取当前菜单激活路径
  activePath = router.currentRoute.value.fullPath;
  activePath2 = router.currentRoute.value.fullPath;
}
setActivePath();
console.log(store.state.user.userInfo);
</script>

<style>
.el-menu-item-group__title{
  display: none;
}
</style>
